//
//  Bullet.m
//  FrameWork
//
//  Created by Eagle on 5/26/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "Bullet.h"


@implementation Bullet

@synthesize type = _type;
@synthesize attack = _attack;
@synthesize slowdown = _slowdown;
@synthesize slowFrame = _slowFrame;
@synthesize angle = _angle;
@synthesize range = _range;
@synthesize status = _status;
@synthesize frame = _frame;
@synthesize dx = _dx;
@synthesize dy = _dy;

@synthesize target = _target;
@synthesize start = _start;
@synthesize end = _end;

+(id) bulletByType:(int)type level:(int)level
{
	Bullet *bullet = nil;
	if ((bullet = [[[super alloc] initWithFile:@"bullet.png"] autorelease])) 
	{
		switch (type) {
			case 1:
			{
				bullet.type = type;
				bullet.attack = [[Parameter sharedParameter] attackArrow:level];
				bullet.slowdown = 0;
				bullet.slowFrame = 0;
				bullet.range = 0;
				bullet.frame = 15;
			}
				break;
			case 2:
			{
				bullet.type = type;
				bullet.attack = [[Parameter sharedParameter] attackPoison:level];
				bullet.slowdown = [[Parameter sharedParameter] slowdown:level];
				bullet.slowFrame = [[Parameter sharedParameter] slowdownTime:level];
				bullet.range = 0;
				bullet.frame = 15;
			}
				break;
			case 3:
			{
				bullet.type = type;
				bullet.attack = [[Parameter sharedParameter] attackPuncture:level];
				bullet.slowdown = 0;
				bullet.slowFrame = 0;
				bullet.range = 0;
				bullet.frame = 15;
			}
				break;
			case 4:
			{
				bullet.type = type;
				bullet.attack = [[Parameter sharedParameter] attackMangonel:level];
				bullet.slowdown = 0;
				bullet.slowFrame = 0;
				bullet.range = [[Parameter sharedParameter] attackMangonelRadius:level];
				bullet.frame = 40;
			}
				break;
			default:
				break;
		}
	}
	return bullet;
}


@end
